import {
  reqPostSearchInfo
} from "../../api"
const state = {
  searchList: {}
}
const mutations = {
  GETSEARCHLIST(state, searchList) {
    state.searchList = searchList
  }
}
const actions = {
  async getSearchList({
    commit
  }, params = {}) {
    // 当用户派发actions的时候，至少传递一个空对象
    await reqPostSearchInfo(params).then((res) => {

      if (res.code == 200) {
        commit('GETSEARCHLIST', res.data)
      }
    })
  },
}
// 当前仓库中的state，并非大仓库的那个state
const getters = {
  goodsList(state) {
    // 如果服务器数据回来了，没问题是一个数组，假如没网的话，至少给一个数组
    return state.searchList.goodsList || []
  },
  trademarkList(state) {
    return state.searchList.trademarkList || []
  },
  attrsList(state) {
    return state.searchList.attrsList || []

  }
}
export default {
  state,
  mutations,
  actions,
  getters
}